package GUI;
/**
 * Histogram frame for the principle
 */

import java.util.Vector;

import javax.swing.*;


public class Histogram  extends JFrame
{
	
	public Login myLoginFrame = null;
	public UserPrinciple user;
	public PrincipleMainMenu prmn = null;
	
//	private int[] data=null;
	private String output="";
	private int i,j,k=0;
	private int[] data = null;
	private int length = 0;
	private Vector<String> classes = null;
	
	public int[] getData() {
		return data;
	}



	public void setData(PrincipleMainMenu prmn) {
	 int temp=0;
		
		for(k=0;k<length;k++)
		{
		System.out.println("Average: "+ prmn.user.dataHistograms.BclassesForTeacher.get(k).AvgGrade);
		temp=prmn.user.dataHistograms.BclassesForTeacher.get(k).AvgGrade;
		this.data[k] = temp;
		System.out.println(data[k]);
		System.out.println(k);
		}
	}



	//private int size;//prmn.user.dataHistograms.BclassesForTeacher.size()
	
	public Histogram(PrincipleMainMenu prmn, int size)
	{
		String output = "";
		this.length=size;
		//k=0;
		data = new int[size];
		classes = new Vector<String>();
		for(i=0;i<prmn.user.dataHistograms.BclassesForTeacher.size();i++)
		{
			classes.add(prmn.user.dataHistograms.BclassesForTeacher.get(i).ClassID);
		}
	
	}
	

public void showHistogram()
{
	System.out.println("data length" +data.length);
	for(i=0;i<data.length;i++)
	{
		System.out.println("Grades "+data[i]);
	}
	 output += "Class \tAvg Grade\tHistogram";
	  
	  for ( i = 0; i < data.length; i++)
	  {
	   output += "\n" + classes.get(i)  + "\t" + data[i] + "\t";
	 
	   //prints the bar
	   for (int j = 1; j <= data[i]/5; j++)
	    output += '*';
	  }
	 
	  JTextArea outputArea = new JTextArea(11, 30);
	  outputArea.setText(output);
	 
	  JOptionPane.showMessageDialog(null , outputArea, "Histogram Class", JOptionPane.INFORMATION_MESSAGE);
}

 public static void main(String args[])
 {
  int n[] = {19, 3, 20, 7, 13, 19, 3, 19,1};
  String output = "";
 
  output += "Element \tValue\tHistogram";
 
  for (int i = 0; i < n.length; i++)
  {
   output += "\n" + i + "\t" + n + "\t";
 
   //prints the bar
   for (int j = 1; j <= n[i]; j++)
    output += '*';
  }
 
  JTextArea outputArea = new JTextArea(11, 30);
  outputArea.setText(output);
 
  JOptionPane.showMessageDialog(null , outputArea,
  "Histogram Class",
  JOptionPane.INFORMATION_MESSAGE);
 
  System.exit(0);
 
 
 }


}